<template>
    <div>
        <div class="screen-demo">
            <div v-if="!item.coverImgUrl" class="empty">
                <img src="@/assets/img/logo-screen.png" />
            </div>
            <div v-else class="screen">
                <div class="top">
                    <img :src="handleImgUrl(item.coverImgUrl, 80)" />
                </div>
                <div class="bottom">
                    <img :src="handleImgUrl(item.bottomImgUrl, 80)" />
                </div>
            </div>
        </div>
        <div class="case-name">
            {{ item.customerName || '-' }}
        </div>
    </div>
</template>

<script setup lang="ts">
import { PropType } from 'vue';
import { PremisesCaseItem } from '../../onePage.module';
import { handleImgUrl } from './adjunct';

defineProps({
    item: {
        type: Object as PropType<PremisesCaseItem>,
        require: true,
        default: () => ({}),
    },
});
</script>

<style lang="scss" scoped>
.screen-demo {
    width: 80%;
    height: 209px;
    background: #f5f7f9;
    border: 0.5px solid #eeeeee;
    border-radius: 4px;
    margin: auto;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;

    .empty {
        width: 28px;
        height: 28px;

        img {
            width: 28px;
            height: 28px;
        }
    }

    .screen {
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;

        .top {
            width: 100%;
            flex: 1;
            height: 0;
            display: flex;

            img {
                width: 100%;
                height: 100%;
            }
        }

        .bottom {
            width: 100%;
            margin-top: 6px;
            display: flex;

            img {
                width: 100%;
                max-height: 60px;
            }
        }
    }
}

.case-name {
    font-family: PingFangSC-Regular, sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #333333;
    letter-spacing: 0.5px;
    text-align: center;
    margin: 8px auto 0;
    width: 80%;
    text-overflow: ellipsis;
    overflow: hidden;
    height: 20px;
}
</style>
